import React, { Component,Suspense } from 'react'
import { Switch,Redirect,Route } from 'react-router-dom'

export class Routerview extends Component {
  render() {
      const {routerConfig}=this.props
      console.log(this.props);
    return (
      <Suspense>
          <Switch>
              
              {routerConfig.length?routerConfig.map((item,index)=>{
                  return item.redirect?<Redirect
                  key={index}
                  to={item.redirect}
                  ></Redirect>:<Route
                  key={index}
                  path={item.path}
                  render={(props)=>{
                      return <item.component
                        {...props}
                        routerConfig={item.children}
                      ></item.component>
                  }}
                  ></Route>
              }):'暂无路由'}
          </Switch>
      </Suspense>
    )
  }
}

export default Routerview